#pragma once

#include <iostream>
#include <string>
#include <unordered_map>
#include <functional>

using std::cout;
using std::endl;
using std::string;
using std::to_string;
using std::unordered_map;
using std::function;

using func_t = function<void(const int &, const string&, const uint16_t&)>;

class Task
{
public:
    Task()
    {}

    Task(const int &sock, const std::string& clientip, const uint16_t& clientport, func_t func)
        :sock_(sock), clientip_(clientip), clientport_(clientport), cb_(func)
    {}

    void operator()()
    {
        //Thread 类中会回调此函数
        //然后回调 service
        cb_(sock_, clientip_, clientport_);
    }

    ~Task()
    {}

private:
    int sock_;
    string clientip_;
    uint16_t clientport_;
    func_t cb_; //回调函数，实际回调 service
};